package hydrap2p.gui.commands;

import hydrap2p.gui.GUIDataHandler;
import hydrap2p.gui.GUIViewHandler;

import java.util.ArrayList;

import org.apache.thrift.TException;

public class Cmd_GUIViewHandler_LoadPreferences implements Command {

	@Override
	public void execute() {
		ArrayList<String> prefs = GUIDataHandler.getInstance().loadPreferences();
		try {
			GUIViewHandler.setFrameWidth(Integer.parseInt(prefs.get(0)));
			GUIViewHandler.setFrameHeight(Integer.parseInt(prefs.get(1)));
			GUIViewHandler.setHorizontalDividerPercentage(Double.parseDouble(prefs.get(2)));
			GUIViewHandler.setVerticalDividerPercentage(Double.parseDouble(prefs.get(3)));
			GUIDataHandler.DOWNLOAD_PATH = prefs.get(4);
		} catch(IndexOutOfBoundsException e) {
			e.printStackTrace();
		}
		
		System.out.println(getCommand());
	}

	@Override
	public String getCommand() {
		return this.getClass().getSimpleName();
	}

	@Override
	public void unexecute() {
		// TODO Auto-generated method stub

	}

}
